package lumis.portal.serialization.persistency;

import java.io.Closeable;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

/**
 * Abstraction of a file repository.
 * 
 * @version $Revision: 6376 $ $Date: 2007-04-10 17:55:53 -0300 (Tue, 10 Apr 2007) $
 * @since 4.0.10
 */
public interface IDirectory extends Closeable
{
	/**
	 * Get an {@link InputStream} to a repository file.
	 * @param filePath path to the file.
	 * @return {@link InputStream} to file found in specified filePath.
	 * @throws FileNotFoundException if no file was found in specified filePath.
	 * @throws IOException if an I/O error occurs.
	 */
	public InputStream getInputStream(String filePath) throws FileNotFoundException, IOException;
	
	/**
	 * Get an {@link OutputStream} to a repository file.
	 * @param filePath path to the file.
	 * @return {@link OutputStream} to the new file
	 * @throws IOException if an I/O error occurs.
	 */
	public OutputStream getOutputStream(String filePath) throws IOException;

	/**
	 * Check the existence of a file.
	 * @param filePath path to the file to be checked.
	 * @return true, if the specified file exists.
	 * @throws IOException if an I/O error occurs.
	 */
	public boolean exists(String filePath) throws IOException;

	/**
	 * Generate a general description of the directory, used mainly to compose exception messages.
	 * @return directory description.
	 */

	public String getDescription();

	/**
	 * Delete the repository.
	 * @throws IOException if an I/O error occurs.
	 */
	public void delete() throws IOException;
}
